package com.blrs.service.project.funding.impl;

import java.util.List;

import com.blrs.common.utils.SecurityUtils;
import com.blrs.common.utils.uuid.IdUtils;
import com.blrs.domain.ProjectFunding;
import com.blrs.mapper.ProjectFundingMapper;
import com.blrs.service.project.funding.IProjectFundingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 项目资金管理Service业务层处理
 * 
 * @author yuxiang.chen
 * @date 2023-08-10
 */
@Service
public class ProjectFundingServiceImpl implements IProjectFundingService
{
    @Autowired
    private ProjectFundingMapper projectFundingMapper;


    /**
     * 查询项目资金管理
     * 
     * @param fundId 项目资金管理主键
     * @return 项目资金管理
     */
    @Override
    public ProjectFunding selectProjectFundingByFundId(String fundId)
    {
        return projectFundingMapper.selectProjectFundingByFundId(fundId);
    }

    /**
     * 查询项目资金管理列表
     * 
     * @param projectFunding 项目资金管理
     * @return 项目资金管理
     */
    @Override
    public List<ProjectFunding> selectProjectFundingList(ProjectFunding projectFunding)
    {
        return projectFundingMapper.selectProjectFundingList(projectFunding);
    }

    /**
     * 新增项目资金管理
     * 
     * @param projectFunding 项目资金管理
     * @return 结果
     */
    @Override
    public int insertProjectFunding(ProjectFunding projectFunding)
    {
        //projectFunding.setFundId(IdUtils.fastUUID());
        projectFunding.setOperateId(SecurityUtils.getUserId());
        projectFunding.setDelFlag("0");
        projectFunding.setOrganizationId(SecurityUtils.getOrgId());
        projectFunding.setOrganizationName(SecurityUtils.getOrgName());
        projectFunding.setDepartmentId(SecurityUtils.getDeptId());
        projectFunding.setDepartmentName(SecurityUtils.getLoginUser().getUser().getDept().getDeptName());
        return projectFundingMapper.insertProjectFunding(projectFunding);
    }

    /**
     * 修改项目资金管理
     * 
     * @param projectFunding 项目资金管理
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateProjectFunding(ProjectFunding projectFunding)
    {
        return projectFundingMapper.updateProjectFunding(projectFunding);
    }

    /**
     * 批量删除项目资金管理
     * 
     * @param fundIds 需要删除的项目资金管理主键
     * @return 结果
     */
    @Override
    public int deleteProjectFundingByFundIds(String[] fundIds)
    {
        return projectFundingMapper.deleteProjectFundingByFundIds(fundIds);
    }

    /**
     * 删除项目资金管理信息
     * 
     * @param fundId 项目资金管理主键
     * @return 结果
     */
    @Override
    public int deleteProjectFundingByFundId(String fundId)
    {
        return projectFundingMapper.deleteProjectFundingByFundId(fundId);
    }
}
